<?php include $this->admin_tpl('meta', 'admin');?>
<title>添加/编辑薪资信息</title>
</head>
<body>
<article class="page-container">
<div class="formdoby_normal">
	<form method="post" onsubmit="return dosub(this)">
		<ul>
			<li>
				<label><span class="c-red">*</span> 员工：</label>
				<?php if(!isset($_GET['member_id'])&&!isset($_GET['id'])){?>
				<select name="member_id" style="width:242px;">
					<option value="">请选择员工</option>
					<?php foreach($member_list as $v){?>
					<option value="<?php echo $v['id'];?>" <?php if($v['id']==$data['member_id']){echo 'selected';}?>><?php echo department($v['department_id']);?>：<?php echo $v['name'];?></option>
					<?php } ?>
				</select>
				<?php }else{ ?>
					<input type="hidden" class="input" name="member_id" value="<?php echo $data['member_id'];?>">
					<span><?php echo department($data['department_id']);?>：<?php echo $data['name'];?></span>
				<?php } ?>
			</li>
			 <li>
				<label><span class="c-red">*</span> 休息天数：</label>
			 	<input type="text" class="input" name="days" value="<?php echo $data['days']?>" placeholder="请输入休息天数"> 天，可以保留最后一位小数
			 </li>
			 <li id="remark">
				<label style="margin-top:-45px;"><span class="c-red">*</span>休息备注：</label>
				<span class="span_input" id="remark">
					<textarea name="remark" class="textarea w_420" rows="2" style="height:50px;" placeholder="开始休息时间~结束时间"><?php echo $data['remark']?></textarea>
				</span>
			 </li>
			 <li>
				<label><span class="c-red">*</span> 休息开始时间：</label>
				<input type="text" class="input-text laydate-icon" style="width:175px;height:30px;" name="action_time" id="action_time" autocomplete="off" value="<?php echo $data['action_time']?date('Y-m-d',$data['action_time']):''; ?>"></span>
			 </li>
			 <li class="text-c">
			 	<input type="hidden" name="dosubmit" value="1">
				<input type="hidden" name="id" value="<?php echo $data['id'];?>">
			 	<input class="dosubmit w_120 btn-primary radius" type="submit" value="提交">
			 	<input class="btn w_120 btn-default radius" type="button" value="取消" onclick="yzmcms_close()">
			 </li>
		</ul>
	</form>
</div>
</article>
<?php include $this->admin_tpl('footer', 'admin');?>
<script type="text/javascript" src="<?php echo STATIC_URL;?>plugin/laydate/1.1/laydate.js"></script>
<script type="text/javascript">
	$("input[name='is_same']").click(function(){
		var obj = $('input[name="bank_account"]');
		if($(this).is(':checked')){
			obj.val($('input[name="name"]').val());
			obj.attr('disabled','disabled');
		}else{
			obj.removeAttr('disabled');
		}
	})
	
	function dosub(obj){
		 if(obj.member_id.value==''){
			 layer.msg('请选择员工！', {icon:2});
			 return false;
		 }
		 if(obj.days.value=='' || isNaN(obj.days.value)){
			 layer.msg('休息天数只能为数字类型！', {icon:2});
			 return false;
		 }
		 if(obj.action_time.value==''){
			 layer.msg('请选择休息开始时间！', {icon:2});
			 return false;
		 }
        $.ajax({
            type: 'POST',
            url: '<?php echo U('leave_add');?>', 
            data: $(obj).serialize(),
		    dataType: "json", 
            success: function (msg) {
			console.log(msg);
				if(msg.status == 1){
					layer.msg(msg.message, {icon:1, time:800}, function(){
						parent.location.reload();
					});
			    }else{
					layer.msg(msg.message, {icon:2});
				}
            }
        })		 
		return false;			 
	}
	var action_time = {elem:'#action_time',format:'YYYY-MM-DD',min:'1999-01-01',max:'2099-01-01',istime:true,istoday:false,choose:function(datas){}
	};
	laydate(action_time);
</script> 

</body>
</html>